//
//  StatusRetweetedCell.swift
//  JLWeibo
//
//  Created by sunjinliang on 15/12/13.
//  Copyright © 2015年 sunjinliang. All rights reserved.
//

import UIKit
import SnapKit
class StatusRetweetedCell: StatusTableViewCell {
    
    
   /// 背景按钮
   lazy var backButton : UIButton = {
       let btn = UIButton()
//         btn.backgroundColor = UIColor(white: 0.95, alpha: 1)
        return btn
    }()
    lazy var retweetedLabel: UILabel = {
       let lab = UILabel(text1: "微博正文", color: UIColor.darkGrayColor(), fontSize: 14)
        lab.textAlignment = .Left
        lab.preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - CGFloat(2 * statusCellMargin)
        return lab
    }()
    override  var statusView: StatusViewModel?{
        didSet{
            retweetedLabel.text = statusView?.retweetedText
            pictureView.snp_updateConstraints { (make) -> Void in
                let offSet = statusView?.thumbnailArray?.count > 0 ? statusCellMargin : 0
                make.top.equalTo(retweetedLabel.snp_bottom).offset(offSet)
            }
        }
    }
    override func setupUI() {
        super.setupUI()
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(retweetedLabel, aboveSubview: backButton)

        
        backButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentLabel.snp_bottom).offset(statusCellMargin)
            make.left.equalTo(contentView.snp_left)
            make.right.equalTo(contentView.snp_right)
            make.bottom.equalTo(bottomView.snp_top)
        }
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(backButton.snp_top)
            make.left.equalTo(backButton.snp_left).offset(statusCellMargin)
        }
        pictureView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedLabel.snp_bottom).offset(statusCellMargin)
            make.left.equalTo(backButton.snp_left).offset(statusCellMargin)
        }
    }
}
